1:ES5 IntroductionECMAScript 5.1 (or ES5 only) is a revision of the ECMAScript (JavaScript-based specification) standard. Similar to the HTML5 specification process, ES5 is standardized by merging existing JavaScript methods with the addition of statements and native ECMAScr
ES5 learning tutorial Array object, es5array object
Preface
Many new things added in ES5 will help us write Javascript. The following describes the Array objects in ES5. Let's take a look at them.
1. syntax for creating an Array object:
new Array();new Array(size);new Array(
may be more convenient and faster. Why use ES5,ES6,TypeScript to demo ? Let's introduce these three concepts:ES5: Full Name ECMAScript5, which can be understood as our regular JavaScript(in fact JavaScript also contains the DOM and the BOM ), which is currently supported by most browsers JavaScript syntax characteris
quickly. But after ECMASCript 3 came out of 1999, there were no changes made to the official for a standard. Instead various browser vendors made their own custom extensions to the language, and Web developers were left to try and Support multiple APIs. Even after ECMAScript 5 is published in 2009, it took several years for wide browser support of the new spec, and most de Velopers continued to write code in ECMAScript 3 style, without necessarily being the aware.
Around things started to cha
There are many methods for JavaScript inheritance, including compile-to-javascript TypeScript, CoffeeScript, and various polyfill implementations provided by the website MDN, GitHub, and Modernizr.From the perspective of ES5, some of these solutions are functional, but the semantics is not satisfactory.I have taken some trendy ideas from these schemes and compile
1, use strict mode, add code specification' Use strict 'This is a good habit to avoid some hidden errors in your code. Strict mode is used by default in ES62, JS ES5 Two ways to declare the method(function () { ' use strict '; // A function expression that assigns a method to a variable, which must be called after the declaration. // recommended ways to use the website var function () { }; // is a function declaration, it will be
1.JavaScript is a dynamic language, the appearance of ES6 make up for JS in large projects on the weakness (with "class").Here is a basic knowledge of ES5:2.Unlike traditional object-oriented languages such as C + + or Java, JavaScript actually pressesGener no class. Everything in the language is object-based and relies on a prototype (prototype) system. andThe p
There's a lot of new stuff in ES5, and knowing it helps us write JavaScript, like arrays, we probably don't need to rhythmic for loops.
The write array method is added to the ES5, as follows:
ForEach (JS v1.6)Map (JS v1.6)Filter (JS v1.6)Some (JS v1.6)Every (JS v1.6)IndexOf (JS v1.6)LastIndexOf (JS v1.6)Reduce (JS v1.8)Reduceright (JS v1.8)
1, JS commonly used
, isextensible.14.SymbolsSymbol is a basic type. The symbol is generated by calling the symbol function, which receives an optional name parameter, and the symbol returned by the function is unique.var key = Symbol ("key"); var key2 = Symbol ("key"= = Key2 //false15.PromisesPromises is an object that handles asynchronous operations and uses a Promise object to organize the code in a chained way, making the code more intuitive (like jquery's deferred object).functionfakeajax (URL) {return NewPro
.PromisesPromises is an object that handles asynchronous operations and uses a Promise object to organize the code in a chained way, making the code more intuitive (like jquery's deferred object).functionfakeajax (URL) {return NewPromise (function(Resolve, reject) {//settimeouts is for effect, typically we would handle XHR if(!URL) { returnSetTimeout (Reject, 1000); } returnSetTimeout (Resolve, 1000); });}//no URL, Promise rejectedFakeajax (). Then (function() {Console.log (' Success
traverses through to the end. The reduceright () begins with the last item in the array and traverses forward to the first item. Both methods receive two parameters: a function that is called on each item and (optionally) as the initial value for narrowing the base. the functions passed to reduce () and Reduceright () receive 4 parameters: the previous value, the current value, the index of the item, and the array object. Description: Use the reduce () method to perform an operation that evalua
the symbol function, which receives an optional name parameter, and the symbol returned by the function is unique.var key = Symbol ("key"); var key2 = Symbol ("key"= = Key2 //false15.PromisesPromises is an object that handles asynchronous operations and uses a Promise object to organize the code in a chained way, making the code more intuitive (like jquery's deferred object).functionfakeajax (URL) {return NewPromise (function(Resolve, reject) {//settimeouts is for effect, typically we would ha
The ES5 syntax does not support class classes, but you can declare a class by clearing the function as follows:function person (name) {This.name=name;}var john=new person (' John ');Console.log (john.name);//johnBut this class can be called directly like function execution: person ()The decision is not to be called by New or () so modify the above class:function person (name) {This.name=name;if (this instanceof person) {Alert (' New call ');}else{Aler
Reference Type of the JavaScript getting started tutorial and javascript getting started tutorial
Reference Type
A reference type is a data structure used to organize data and functions together. It is also often called a class, but this name is not appropriate. Although ECMAScript is technically an object-oriented lan
This tutorial provides a relatively complete basic knowledge for those who have not been familiar with JavaScript, but only limited to the basic knowledge.
JavaScript reference
This tutorial provides a relatively complete basic knowledge for those who have not been familiar with J
JavaScript: elementary JavaScript tutorial (6). The Javascript tutorial uses the internal Object System of the browser to interact with HTML documents. It is used to organize and package related elements for program designers, so as to reduce the work of programmers and impr
This article describes how to quickly learn JavaScript free tutorial resources for beginners. It is a very good learning site. If you need it, you can refer to it. JavaScript is familiar to everyone, but only a small number of people know how to use it and how to build applications. This "small part" of people refer to the talented young people, network programme
shorthand way to access the object's properties, but we still have conflicting views on whether we should use it. Douglas Crockford doesn't like it very much. John Resig in his book a lot of clever use of with, but he admits it will affect performance and create a bit of confusion. Let's look at our detached with code block, he can't tell us exactly what we're doing now, the code looks like this:
1 2 3 4
With (obj) {bob = "MMM"; eric = 123;}
Have I just modified a loc
Main introduction: JavaScript reinforcement tutorial-JavaScript operator JavaScript Arithmetic Operator this article is an official HTML5 training tutorial for H5EDU institutions, mainly about: JavaScript reinforcement
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.